//
//  FileManagerExt.swift
//  kano
//
//  Created by Sophia on 2024/8/14.
//

import Foundation

extension FileManager {
    class func ka_urlForDirectory(directory: SearchPathDirectory) -> URL {
        self.default.urls(for: directory, in: .userDomainMask).last!
    }
    
    class func ka_pathForDirectory(directory: SearchPathDirectory) -> String {
        NSSearchPathForDirectoriesInDomains(directory, .userDomainMask, true).first!
    }
    
    class func ka_documentsURL() -> URL {
        ka_urlForDirectory(directory: .documentDirectory)
    }
    
    class func ka_documentsPath() -> String {
        ka_pathForDirectory(directory: .documentDirectory)
    }
    
    class func ka_libraryURL() -> URL {
        ka_urlForDirectory(directory: .libraryDirectory)
    }
    
    class func ka_libraryPath() -> String {
        ka_pathForDirectory(directory: .libraryDirectory)
    }
    
    class func ka_cachesURL() -> URL {
        ka_urlForDirectory(directory: .cachesDirectory)
    }
    
    class func ka_cachesPath() -> String {
        ka_pathForDirectory(directory: .cachesDirectory)
    }
}

